package com.sky.mapper;

import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 批量插入菜品套餐信息
     * @param setmealDishes
     */
    public void insertBatch(List<SetmealDish> setmealDishes);

    /**
     * 根据菜品id查询套餐id
     * @param ids
     * @return
     */
    public List<Long> getSetmealIdByDishId(List<Long> ids);

    /**
     * 根据套餐id集合批量删除相关信息
     * @param ids
     */
    void deleteBySetmealIds(List<Long> ids);

    /**
     * 根据套餐id查询套餐菜品信息
     * @param id
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id};")
    List<SetmealDish> getBySetmealId(Long id);

    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteBySetmealId(Long id);

    /**
     * 根据套餐id查询相关菜品信息
     * @param id
     * @return
     */
    @Select("select d.name, sd.copies, d.image, d.description from setmeal_dish sd left join dish d on d.id = sd.dish_id " +
            "where sd.setmeal_id = #{id}")
    List<DishItemVO> getDishItemById(Long id);
}
